package com.china08.yxyapi.service.mg.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.china08.yxyapi.entity.mg.statistics.SchoolUploadResourceReport;
import com.china08.yxyapi.repository.mg.statistics.SchoolUploadWeikeReportRepository;
import com.china08.yxyapi.service.mg.WeiKeCountSchoolListService;
@Service
public class WeikeCountSchoolListServiceImpl implements WeiKeCountSchoolListService {
	   @Autowired
	   private SchoolUploadWeikeReportRepository schoolUploadWeikeReportRepository;
	
	  /**
	   * 获取地区
	   */
      @Override
      public Page<SchoolUploadResourceReport> getAreaContent(String districtCode,String cityName,String areaName,String phaseName,String schoolName,String listOrder,Pageable pageable){
    	  Page<SchoolUploadResourceReport> schoolUploadResourceReportLst=null;
    	  if (schoolName!=null && !schoolName.equals("")) {//如果学校不为空
      		schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndSchoolNickLike(districtCode,schoolName,pageable);
				if (phaseName!=null && !phaseName.equals("")) {//如果学校不为空和学段不为空
					schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLike(districtCode,phaseName,schoolName,pageable);
					if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和学段不为空和列表排序不为空
						   if (listOrder.equals("微课总数从高到低")) {	
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,phaseName,schoolName,pageable); 
						   }
						   if (listOrder.equals("微课共享从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,phaseName,schoolName,pageable); 
						   }
					}
				}else
				if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和列表排序不为空
					   if (listOrder.equals("微课总数从高到低")) {	
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,schoolName,pageable); 
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,schoolName,pageable); 
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,schoolName,pageable);
					   }
				}
			}else{//如果学校为空
				if (phaseName!=null && !phaseName.equals("")) {//如果学校为空和学段不为空
					schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageIn(districtCode,phaseName,pageable);
					if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和学段不为空和列表排序不为空
						   if (listOrder.equals("微课总数从高到低")) {	
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInOrderByWeikeCountDesc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInOrderByWeikeCountAsc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInOrderByShareWeikeCountDesc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("微课共享从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictAndStageInOrderByShareWeikeCountAsc(districtCode,phaseName,pageable);
						   }
					}
				}else
				if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和列表排序不为空
					   if (listOrder.equals("微课总数从高到低")) {	
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictOrderByWeikeCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictOrderByWeikeCountAsc(districtCode,pageable);
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictOrderByShareWeikeCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictOrderByShareWeikeCountAsc(districtCode,pageable);
					   }
				}
			}
    	  if (schoolUploadResourceReportLst==null) {			
    		  schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdDistrictOrderByWeikeCountDesc(districtCode,pageable);
		  }
	    return schoolUploadResourceReportLst;
      }
      /**
	   * 获取市
	   */
      @Override
      public Page<SchoolUploadResourceReport> getCityContent(String districtCode,String cityName,String areaName,String phaseName,String schoolName,String listOrder,Pageable pageable){
    	  Page<SchoolUploadResourceReport> schoolUploadResourceReportLst=null;
      if (schoolName!=null && !schoolName.equals("")) {//如果学校不为空
			schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndSchoolNickLike(districtCode,schoolName,pageable);
//		   if (cityName!=null&&!cityName.equals("")) {//如果城市不为空和学校不为空
			
			   if (areaName!=null && !areaName.equals("")) {//如果区县不为空和学校不为空
				   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLike(districtCode,areaName,schoolName,pageable);
				  if(phaseName!=null && !phaseName.equals("")){//如果学段不为空和区县不为空和学校不为空
					  schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLike(districtCode,areaName,phaseName,schoolName,pageable);
					  
					   if(listOrder!=null && !listOrder.equals("")){//如果列表排序不为空和学段不为空和区县不为空和学校不为空
						   
						   
						   if (listOrder.equals("微课总数从高到低")) {	//如果列表排序是微课总数从高到低，   和学段不为空和区县不为空和学校不为空							   
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {//如果列表排序是微课总数从低到高，   和学段不为空和区县不为空和学校不为空
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {//如果列表排序是微课共享从高到低，   和学段不为空和区县不为空和学校不为空
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从低到高")) {//如果列表排序是微课共享从低到高，   和学段不为空和区县不为空和学校不为空
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
					   }
					   
				  }else
				  if(listOrder!=null && !listOrder.equals("")){//如果区县不为空和学校不为空列表排序不为空
					   if (listOrder.equals("微课总数从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,areaName,schoolName,pageable);
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,areaName,schoolName,pageable);
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,areaName,schoolName,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,areaName,schoolName,pageable);
					   }
					   
				  }
			   }else
			   if(listOrder!=null && !listOrder.equals("")){//如果学校不为空和列表排序不为空
				   
				   if (listOrder.equals("微课总数从高到低")) {
					   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,schoolName,pageable);
				   }
				   if (listOrder.equals("微课总数从低到高")) {
					   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,schoolName,pageable);
				   }
				   if (listOrder.equals("微课共享从高到低")) {
					   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,schoolName,pageable);
				   }
				   if (listOrder.equals("微课共享从低到高")) {
					   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,schoolName,pageable);
				   }
			   }
//		   }
		}else{//如果没有学校的模糊查询
//			if (cityName!=null&&!cityName.equals("")) {//如果学校为空
				
				   if (areaName!=null && !areaName.equals("")) {//如果区县不为空和学校为空
					   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrict(districtCode,areaName,pageable);
					  if(phaseName!=null && !phaseName.equals("")){//如果学段不为空和区县不为空和学校为空
						  schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageIn(districtCode,areaName,phaseName,pageable);
						   if(listOrder!=null && !listOrder.equals("")){//如果列表排序不为空和学段不为空和区县不为空和学校为空
							   if (listOrder.equals("微课总数从高到低")) {						   
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByWeikeCountDesc(districtCode,areaName,phaseName,pageable);
							   }
							   if (listOrder.equals("微课总数从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByWeikeCountAsc(districtCode,areaName,phaseName,pageable);
							   }
							   if (listOrder.equals("微课共享从高到低")) {
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByShareWeikeCountDesc(districtCode,areaName,phaseName,pageable);
							   }
							   if (listOrder.equals("微课共享从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByShareWeikeCountAsc(districtCode,areaName,phaseName,pageable);
							   }
						   }
					  }else{
						  if(listOrder!=null && !listOrder.equals("")){//如果列表排序不为空和学段为空和区县不为空和学校为空
							   if (listOrder.equals("微课总数从高到低")) {						   
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByWeikeCountDesc(districtCode,areaName,pageable);
							   }
							   if (listOrder.equals("微课总数从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByWeikeCountAsc(districtCode,areaName,pageable);
							   }
							   if (listOrder.equals("微课共享从高到低")) {
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByShareWeikeCountDesc(districtCode,areaName,pageable);
							   }
							   if (listOrder.equals("微课共享从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByShareWeikeCountAsc(districtCode,areaName,pageable);
							   }
						   }
					  }
				   }else
				   if(phaseName!=null && !phaseName.equals("")){//如果学段不为空和学校为空
					   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByStageInAndAreaIdCity(phaseName,districtCode,pageable);
					   if(listOrder!=null && !listOrder.equals("")){//如果学段不为空和列表排序不为空和学校为空
						   if (listOrder.equals("微课总数从高到低")) {	
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndStageInOrderByWeikeCountDesc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndStageInOrderByWeikeCountAsc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndStageInOrderByShareWeikeCountDesc(districtCode,phaseName,pageable); 
						   }
						   if (listOrder.equals("微课共享从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityAndStageInOrderByShareWeikeCountAsc(districtCode,phaseName,pageable); 
						   }
					   }
				   }else
//			   }
			   if(listOrder!=null && !listOrder.equals("")){//如果学校为空和列表排序不为空
				   if (listOrder.equals("微课总数从高到低")) {						   
					   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityOrderByWeikeCountDesc(districtCode,pageable);
				   }
				   if (listOrder.equals("微课总数从低到高")) {
					   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityOrderByWeikeCountAsc(districtCode,pageable);
				   }
				   if (listOrder.equals("微课共享从高到低")) {
					   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityOrderByShareWeikeCountDesc(districtCode,pageable);
				   }
				   if (listOrder.equals("微课共享从低到高")) {
					   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityOrderByShareWeikeCountAsc(districtCode,pageable);
				   }
			   }
		}
        if (schoolUploadResourceReportLst==null) {			
        	schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdCityOrderByWeikeCountDesc(districtCode,pageable);
		}
        return schoolUploadResourceReportLst;
      }
      /**
	   * 获取省
	   */
      @Override
      public Page<SchoolUploadResourceReport> getProvinceContent(String districtCode,String cityName,String areaName,String phaseName,String schoolName,String listOrder,Pageable pageable){
    	  Page<SchoolUploadResourceReport> schoolUploadResourceReportLst=null;
    	  if (schoolName!=null && !schoolName.equals("")) {//如果学校不为空
				schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndSchoolNickLike(districtCode,schoolName,pageable);
				if (cityName!=null && !cityName.equals("")) {//如果学校不为空和城市不为空
					schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLike(districtCode,cityName,schoolName,pageable);
					if (areaName!=null && !areaName.equals("")) {//如果学校不为空和城市不为空和区县不为空
						schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLike(districtCode,cityName,areaName,schoolName,pageable);
						if (phaseName!=null && !phaseName.equals("")) {//如果学校不为空和城市不为空和区县不为空和学段不为空
							schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLike(districtCode,cityName,areaName,phaseName,schoolName,pageable);	
							if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和城市不为空和区县不为空和学段不为空和列表排序不为空
								   if (listOrder.equals("微课总数从高到低")) {	
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,cityName,areaName,phaseName,schoolName,pageable);
								   }
								   if (listOrder.equals("微课总数从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,cityName,areaName,phaseName,schoolName,pageable);  
								   }
								   if (listOrder.equals("微课共享从高到低")) {
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,cityName,areaName,phaseName,schoolName,pageable);
								   }
								   if (listOrder.equals("微课共享从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,cityName,areaName,phaseName,schoolName,pageable);
								   }
							}
						}else
						if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和城市不为空和区县不为空和列表排序不为空
							   if (listOrder.equals("微课总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,cityName,areaName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,cityName,areaName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,cityName,areaName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,cityName,areaName,schoolName,pageable);
							   }
						}
					}else if(cityName!=null && !cityName.equals("") && phaseName!=null && !phaseName.equals("")){//市和学段和学校不为空
						schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLike(districtCode,cityName,phaseName,schoolName,pageable);
						if (listOrder!=null && !listOrder.equals("")) {//如果区和学校和列表排序不为空
							   if (listOrder.equals("微课总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
						 }
					}else
					    if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和城市不为空和列表排序不为空
						   if (listOrder.equals("微课总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,cityName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,cityName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,cityName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,cityName,schoolName,pageable);
						   }
					   }
					
				}else  if (areaName!=null && !areaName.equals("")){//区和学校不为空
					schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLike(districtCode,areaName,schoolName,pageable);
					if (areaName!=null && !areaName.equals("") && phaseName!=null && !phaseName.equals("")) {
						schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLike(districtCode,areaName,phaseName,schoolName,pageable);
						if (listOrder!=null && !listOrder.equals("")) {//如果区和学校和列表排序不为空
							   if (listOrder.equals("微课总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("微课共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
						 }
					}else
					if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和区和列表排序不为空
						   if (listOrder.equals("微课总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,areaName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,areaName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,areaName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,areaName,schoolName,pageable);
						   }
					 }
				}else if(phaseName!=null && !phaseName.equals("")){//学段和学校不为空
					schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLike(districtCode,phaseName,schoolName,pageable);	
					if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和学段和列表排序不为空
						   if (listOrder.equals("微课总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("微课共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,phaseName,schoolName,pageable);
						   }
					 }
				}else 
				if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和列表排序不为空
					   if (listOrder.equals("微课总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByWeikeCountDesc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByWeikeCountAsc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByShareWeikeCountDesc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByShareWeikeCountAsc(districtCode,schoolName,pageable);
					   }
				 }
			}else{//如果学校为空
				if (cityName!=null && !cityName.equals("")) {//如果学校为空和城市不为空
					schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCity(districtCode,cityName,pageable);
					if (areaName!=null && !areaName.equals("")) {//如果学校为空和城市不为空和区县不为空
						schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrict(districtCode,cityName,areaName,pageable);
						if (phaseName!=null && !phaseName.equals("")) {//如果学校为空和城市不为空和区县不为空和学段不为空
							schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageIn(districtCode,cityName,areaName,phaseName,pageable);
							if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和区县不为空和学段不为空和列表排序不为空
								   if (listOrder.equals("微课总数从高到低")) {	
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByWeikeCountDesc(districtCode,cityName,areaName,phaseName,pageable);   
								   }
								   if (listOrder.equals("微课总数从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByWeikeCountAsc(districtCode,cityName,areaName,phaseName,pageable); 
								   }
								   if (listOrder.equals("微课共享从高到低")) {
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByShareWeikeCountDesc(districtCode,cityName,areaName,phaseName,pageable); 
								   }
								   if (listOrder.equals("微课共享从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByShareWeikeCountAsc(districtCode,cityName,areaName,phaseName,pageable);
								   }
							}
						}else
						if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和区县不为空和列表排序不为空
							   if (listOrder.equals("微课总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByWeikeCountDesc(districtCode,cityName,areaName,pageable);
							   }
							   if (listOrder.equals("微课总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByWeikeCountAsc(districtCode,cityName,areaName,pageable);
							   }
							   if (listOrder.equals("微课共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByShareWeikeCountDesc(districtCode,cityName,areaName,pageable);
							   }
							   if (listOrder.equals("微课共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByShareWeikeCountAsc(districtCode,cityName,areaName,pageable);
							   }
						}
					}else if (phaseName!=null && !phaseName.equals("")){//如果学校为空和城市不为空和区县为空和学段不为空
						schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageIn(districtCode,cityName,phaseName,pageable);
						if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和区县为空和学段不为空和列表排序不为空
							   if (listOrder.equals("微课总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByWeikeCountDesc(districtCode,cityName,phaseName,pageable);
							   }
							   if (listOrder.equals("微课总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByWeikeCountAsc(districtCode,cityName,phaseName,pageable);
							   }
							   if (listOrder.equals("微课共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByShareWeikeCountDesc(districtCode,cityName,phaseName,pageable);
							   }
							   if (listOrder.equals("微课共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByShareWeikeCountAsc(districtCode,cityName,phaseName,pageable);
							   }
						}
					}else
					if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和列表排序不为空
						   if (listOrder.equals("微课总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByWeikeCountDesc(districtCode,cityName,pageable);
						   }
						   if (listOrder.equals("微课总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByWeikeCountAsc(districtCode,cityName,pageable);
						   }
						   if (listOrder.equals("微课共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByShareWeikeCountDesc(districtCode,cityName,pageable);
						   }
						   if (listOrder.equals("微课共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByShareWeikeCountAsc(districtCode,cityName,pageable);
						   }
					}
				}else if (areaName!=null && !areaName.equals("") && phaseName!=null && !phaseName.equals("")){//区和学段不为空
					schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageIn(districtCode,areaName,phaseName,pageable);
					if (listOrder.equals("微课总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByWeikeCountDesc(districtCode,areaName,phaseName,pageable);
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByWeikeCountAsc(districtCode,areaName,phaseName,pageable);
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByShareWeikeCountDesc(districtCode,areaName,phaseName,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByShareWeikeCountAsc(districtCode,areaName,phaseName,pageable);
					   }
				}else if (areaName!=null && !areaName.equals("") && listOrder!=null && !listOrder.equals("")) {//区和排序不为空
					if (listOrder.equals("微课总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByWeikeCountDesc(districtCode,areaName,pageable);
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByWeikeCountAsc(districtCode,areaName,pageable);
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByShareWeikeCountDesc(districtCode,areaName,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByShareWeikeCountAsc(districtCode,areaName,pageable);
					   }
				}else if (phaseName!=null && !phaseName.equals("") && listOrder!=null && !listOrder.equals("")) {//学段和排序不为空
					   if (listOrder.equals("微课总数从高到低")) {	
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInOrderByWeikeCountDesc(districtCode,phaseName,pageable);
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInOrderByWeikeCountAsc(districtCode,phaseName,pageable);  
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInOrderByShareWeikeCountDesc(districtCode,phaseName,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceAndStageInOrderByShareWeikeCountAsc(districtCode,phaseName,pageable);
					   }
				}else
				if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和列表排序不为空
					   if (listOrder.equals("微课总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceOrderByWeikeCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("微课总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceOrderByWeikeCountAsc(districtCode,pageable);
					   }
					   if (listOrder.equals("微课共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceOrderByShareWeikeCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("微课共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadWeikeReportRepository.findByAreaIdProvinceOrderByShareWeikeCountAsc(districtCode,pageable);
					   }
				}
			}
    	  if (schoolUploadResourceReportLst==null) {			
    		  schoolUploadResourceReportLst=schoolUploadWeikeReportRepository.findByAreaIdProvinceOrderByWeikeCountDesc(districtCode,pageable);
		   }
    	  return schoolUploadResourceReportLst;
      }
}
